export const namespace = "contentExam";
import { history } from "umi";

export const calcColumns = (params) => {
  const columns = [
    {
      title: "试卷ID",
      dataIndex: "id",
      hideInSearch: true,
    },
    {
      title: "试卷名称",
      dataIndex: "examName",
    },
    {
      title: "含有题目数",
      dataIndex: "questionCount",
      hideInSearch: true,
    },
    {
      title: "试卷描述",
      dataIndex: "examDesc",
      hideInSearch: true,
    },
    {
      title: "试卷分值",
      dataIndex: "totalScore",
      hideInSearch: true,
    },
    {
      title: "测试记录",
      dataIndex: "test",
      hideInSearch: true,
      align: "left",
      render: (_, record) => (
        <a
          onClick={() => {
            history.push(`/content/exam/records/${record.id}`);
          }}
        >
          查看明细
        </a>
      ),
    },
    {
      title: "状态",
      dataIndex: "status",
      valueEnum: {
        0: { text: "上架", status: "Success" },
        1: { text: "下架", status: "Default" },
      },
    },
  ];
  if (params?.operate) {
    columns.push(params?.operate);
  }
  return columns;
};
